//
//  YHHomeCellModel.swift
//  WeiBoYH
//
//  Created by yanhui on 2017/1/9.
//  Copyright © 2017年 yanhui. All rights reserved.
//

import UIKit

class YHHomeCellModel: NSObject {

    var headURL: URL?
    
    
    //用户等级的icon  -> UIImage
    var mbrankImage: UIImage?
    
    //用户认证类型的icon
    var verifiedImage: UIImage?
    
    var status: YHStatus? {
        didSet {
            //处理需要处理的数据
            headURL = URL(string: status?.user?.avatar_large ?? "")
            
            //给image对象赋值
            dealMbrankImage()
            dealverifiedImage()
        }
    }
    
    private func dealMbrankImage() {
        let mbrank = status?.user?.mbrank ?? 0
        if mbrank > 0 && mbrank < 7 {
            mbrankImage = UIImage(named: "common_icon_membership_level\(mbrank)")
        } else {
            mbrankImage = #imageLiteral(resourceName: "common_icon_membership_expired")
        }
    }
    
    private func dealverifiedImage() {
        
        let  verifiedType = status?.user?.verified_type ?? -1
        switch verifiedType {
        case 0:
            verifiedImage = #imageLiteral(resourceName: "avatar_vip")
        case 2,3,5:
            verifiedImage = #imageLiteral(resourceName: "avatar_enterprise_vip")
        case 220:
            verifiedImage = #imageLiteral(resourceName: "avatar_grassroot")
        default:
            print("没有认证")
        }
        
    }
    

    
}
